package pearson.automation;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;

import pearson.automation.forms.BrowseForm;
import pearson.automation.forms.StartForm;

public class BasePearsonTestLogin extends BasePearsonTest {

    /**
     * Performing 'login' operation before each test class. Login\password are
     * selected by getLogin()\getPassword() methods
     */
    protected BrowseForm mainForm;
    
    @BeforeClass(groups = "Base")
    public void doBeforeClass() {
        super.doBeforeClass();
    logStep("Go to main page");
        StartForm start = new StartForm();
        //Log revision and 
        if (start.getBuildRevision() != null) {
            info(String.format("Running on %s", start.getBuildRevision()));
        }
        start.goToLogin().login(getLogin(), getPassword());
        
    logStep("Go to Browse form");
        mainForm = new BrowseForm();
    }
    
    @AfterClass(groups = {"Base"})
    public void logout() {
    logStep("Logout");
        browser.getDriver().navigate().to(browser.getStartBrowserURL());
        mainForm = new BrowseForm();
        mainForm.clickLogout();
    }
}
